package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.UserQuery;
import cn.wolfcode.trip.base.service.IUserService;
import cn.wolfcode.trip.base.util.JSONResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/followAndFans")
public class FollowAndFansController {
    @Autowired
    private IUserService userService;

    /**
     * 查询关注和粉丝
     * @param qo
     * @return
     */
    @GetMapping
    public PageInfo ListFollowAndFansById(UserQuery qo) {
        return userService.selectFollowAndFansById(qo);
    }

    /**
     * 取消关注
     * @return
     */
    @DeleteMapping
    public JSONResult deleteUserByFans(UserQuery qo) {
        userService.deleteUserByFans(qo);
        return new JSONResult();
    }
    /**
     * 关注
     * @return
     */
    @PostMapping
    public JSONResult saveUserByFans(UserQuery qo) {
        userService.saveUserByFans(qo);
        return new JSONResult();
    }

    /**
     * 查询该用户某个粉丝的信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public User getById(@PathVariable Long id) {
        return userService.getById(id);
    }
}
